$(function () {
    //编辑促销员
    $("[name='btn_save_edit_salesman']").click(function () {
        var form = window.form_edit_salesman;
        var id = form.hidden_id.value;
        var name = form.name.value;
        var phone = form.phone.value;
        var branchname = form.branchname.value;
        var adname = form.adname.value;
        var adcode = form.adcode.value;
        var address = form.address.value;
        var state = form.state.value;
        var salesman = {id: id, name: name, phone: phone, branchname: branchname, adname: adname, address: address, adcode: adcode, state: state};
        $.postJsonBody("/salesman/" + id, salesman, function (re) {
        	history.go(-1);
        	window.location.href=window.location.href; 
        	window.location.reload; 
        })
    });


    //同步促销员至企业号
    $("#btn_start_sync_user_to_qyh").click(function () {
        $.post("/weixinqyh/sync/salesman", {departmentId: 1}, function (re) {
            console.log(re);
        });
    });

    


	//触发省市县插件
	$(".area").click(function (e) {
		SelCity(this,$(this),e);
	});
  
	
});



//数据导出
$("[name='btn_export']").click(function () {
    var keyword = $("[name='keyword']").val();
    var state = $("[name='state']").val();
   
    //有数据时才能导出
    if($("#resultTotal_hidden").val() != 0){
    	bootbox.bconfirm("确定是否导出？", function (re) {
            if (re) {
            	 var url="/salesman/export?keyword="+keyword+"&state="+state;
                 window.open(url);
            }
        });
    }else{
    	bootbox.balert("没有数据，无法导出!");
    }
});

